//
//  main.m
//  03-HomeWork
//
//  Created by dllo on 16/7/6.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "BookManager.h"
#import "Book.h"
int main(int argc, const char * argv[]) {
   /*
    1.截取字符串 "20|https://www.baidu.com" 中 "|" 前面和后⾯的字符串, 并输出
    2.向可变数组里存储 int、float、double、BOOL类型等数据(不能使用字面量)
    3.实现图书管理系统(BookManager类)：
      使用数组管理所有书籍(Book类)。
      BookManager类属性数组可以添加、删除。
      可以从数组根据书名查找书籍，并修改书籍的价格。
      展示所有书籍清单（书名）
    */
    
    // 1.
    NSString *string = @"20|https://www.baidu.com";
    NSArray *strArray = [string componentsSeparatedByString:@"|"];
    NSString *frontStr = [strArray objectAtIndex:0];
    NSString *backStr = [strArray objectAtIndex:1];
    NSLog(@"frontStr = %@\nbackStr = %@", frontStr, backStr);
    
    // 2.
    int a = 1;
    float b = 2.33;
    double c = 4.333;
    BOOL isTure = 1;
    NSMutableArray *arr = [NSMutableArray arrayWithObjects:[NSString stringWithFormat:@"%d", a], [NSString stringWithFormat:@"%.2f", b],[NSString stringWithFormat:@"%.3f", c], [NSString stringWithFormat:@"%d", isTure], nil];
    NSLog(@"%@",arr);
    
    // 3.
    Book *book1 = [[Book alloc] initWithName:@"小说" withPrice:10];
    Book *book2 = [[Book alloc] initWithName:@"传记" withPrice:20];
    Book *book3 = [[Book alloc] initWithName:@"novel" withPrice:30];
    BookManager *bookM = [[BookManager alloc] init];
    bookM.bookArray = [NSMutableArray arrayWithObjects:book1, book2, nil];
    [bookM addBooks:book3];
    [bookM dele:book3];
    [bookM modi:@"小说" withPrice:20];
    [bookM show];
    return 0;
}
